<template>
    <section class="watchSection">
        <layout :isVertical="true">
            <common-toolbar text="已确认信息日志">
                <el-button class="btn commonButton" type="default" @click="getShanxuan">筛选</el-button>
            </common-toolbar>
            <div>
                <formData ref="componentChild" :conmonDisabled="conmonDisabled" :list="list" @condition="condition" @conmonDisabledNone="conmonDisabledNone"></formData>
            </div>
            <layout layout="center"  class="centerSection noScrollSection">
               <el-table
                       :data="data"
                       v-loading.iTable="loading"
                       :stripe="true"
                       ref="mutipleTable"
                       :height="height"
                       :highlight-current-row="true"
                       border
                       :tree-props="{children: 'children'}"
                       row-key="id"
                       header-row-class-name="tableHeader"
                       tooltip-effect="dark"
                       class="watchTable"
                       style="width: 100%">
                        <el-table-column
                           label="No."
                           type="index"
                           :index="indexMethod"
                           width="50">
                   </el-table-column>
                   <el-table-column
                           property="cinemaName"
                           label="影院名称"
                           :show-overflow-tooltip="true"
                           width="280"
                    >
                   </el-table-column>
                   <el-table-column
                           property="cinemaCode"
                           label="专资编码"
                           width="150">
                   </el-table-column>
                   <el-table-column
                           property="createTime"
                           label="信息变更时间">
                           <template slot-scope="scope">
                               <p>{{scope.row.createTime}}</p>
                           </template>
                   </el-table-column>
                   <el-table-column
                           property="changeTypeDesc"
                           label="信息变更类型"
                           :show-overflow-tooltip="true">
                   </el-table-column>
                   <el-table-column
                           property="confirmTime"
                           label="信息确认时间">
                           <template slot-scope="scope">
                               <p>{{scope.row.confirmTime}}</p>
                           </template>
                   </el-table-column>
                   
                  <el-table-column
                           property="confirmUser"
                           label="确认人"
                           :show-overflow-tooltip="true">
                   </el-table-column>
                    <el-table-column
                           property="flagMessage"
                           label="是否需光峰人工服务"
                           :show-overflow-tooltip="true">
                   </el-table-column>
                   <el-table-column
                           property="statusDesc"
                           label="数据更新情况"
                           :show-overflow-tooltip="true">
                   </el-table-column>
                   <el-table-column
                           property="message"
                           label="描述"
                           :show-overflow-tooltip="true">
                   </el-table-column>
                   <el-table-column
                           property="province"
                           label="操作">
                            <template slot-scope="scope">
                                <button @click="flmRepeatSync(scope.row)" :disabled="scope.row.button?false:true">再次同步</button>
                                <!-- <a href="javascript:void(0)"  @click="flmRepeatSync(scope.row)" :disabled="!scope.row.button?false:true">再次同步</a> -->
                            </template>
                   </el-table-column>
               </el-table>
                <div class="paginationDiv">
                    <el-pagination
                            background
                            layout="prev, pager, next"
                            @current-change="handleCurrentChange"
                            :current-page.sync="page"
                            :page-size="pageSize"
                            :total="total">
                    </el-pagination>
                </div>
               
            </layout>
        </layout>
        <el-dialog
                title="筛选"
                :visible.sync="dialogVisible"
                width="30%">
            <div>
                <el-form ref="form" :model="form" label-width="80px">
                    <el-form-item label="专资编码">
                        <el-input size="small" v-model="form.code"></el-input>
                    </el-form-item>
                    <el-form-item label="专资编码">
                        <el-input size="small" v-model="form.name"></el-input>
                    </el-form-item>
                    <el-form-item label="影院地址">
                        <el-input size="small" v-model="form.name"></el-input>
                    </el-form-item>
                    <el-form-item label="信息变更时间">
                        <el-input size="small" v-model="form.name"></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer" style="padding:10px;">
                <el-button class="btn commonButton" @click="dialogVisible = false">取 消</el-button>
                <el-button class="btn commonButton" type="default" @click="dialogVisible = false">确 定</el-button>
            </span>
        </el-dialog>
    </section>
</template>

<script lang="ts">
	import Vue from 'vue';
    import Component from 'vue-class-component';
    import Service from './cinemaList.service';
    import formData from '@/views/form/form.vue';

    import {JSEncrypt} from 'jsencrypt';
    import base from '@/scrollLoad';
    import moment from 'moment';

    @Component({components:{
        formData
    }})
    export default class cinemaList extends Vue{
        height = 500;
        windowHeight = 700;
        loading = false;
        data = [];
        onlyShowError = false;
        total = 0;
        page = 1;
        pageSize = 30;
        cinemaName = '';
        cinemaCode = '';
        conmonDisabled:boolean=false;
        dialogVisible = false;
        createTimeBegin = '';
        createTimeEnd = '';
        confirmTimeBegin = '';
        confirmTimeEnd = '';
        status = '';
        list='';
        form = {
            name: '',
            code: '',
            date : ''
        };
        constructor(){
            super();
        };
        // 序号
        indexMethod(index) {
        return (this.page - 1) * this.pageSize + index + 1;
        }
        searchErrorList(){
            this.onlyShowError = true;
            this.searchList();
        }
        
        searchAllList(){
            this.onlyShowError = false;
            this.searchList();
        }

        searchList(){
            this.data = [];
            let userInfoForm = JSON.parse(window.sessionStorage.getItem('userInfoForm'));
            let params = {
                pageNum: this.page,
                pageSize: this.pageSize,
                cinemaName: this.cinemaName,
                cinemaCode: this.cinemaCode,
                headquartersCode:userInfoForm.headquartersCode,
                createTimeBegin:this.createTimeBegin==''? '' : moment(this.createTimeBegin).format('YYYY-MM-DD HH:mm:ss'),
                createTimeEnd:this.createTimeEnd==''? '' :moment(this.createTimeEnd).format('YYYY-MM-DD HH:mm:ss'),
                confirmTimeBegin:this.confirmTimeBegin==''? '' : moment(this.confirmTimeBegin).format('YYYY-MM-DD HH:mm:ss'),
                confirmTimeEnd:this.confirmTimeEnd==''? '' :moment(this.confirmTimeEnd).format('YYYY-MM-DD HH:mm:ss'),
                status:this.status
            }
            
            //console.log(params,this.createTimeBegin.length)
            Service.flmListTask(params).then((res)=>{
                if(res.data.retMessage=='成功'){
                    // this.findByPropertyCodeList = res.data
                    this.data = res.data.result.list;
                    this.total = res.data.result.totalRows;
                }else{
                    this['$message']({
                        message: res.data.retMessage,
                        type: 'error'
                    });
                }
               
            })
        }
        flmRepeatSync(row) {
            let params = {
                taskId:row.taskId
            }
            
            Service.flmRepeatSync(params).then((res)=>{
                if(res.data.retMessage=='成功'){
                    // this.findByPropertyCodeList = res.data
                   this['$message']({
                        message: res.data.retMessage,
                        type: 'success'
                    });
                }else{
                    this['$message']({
                        message: res.data.retMessage,
                        type: 'error'
                    });
                }
               
            })
        }
        handleSizeChange(val) {
            this.pageSize = val;
            this.searchList();
        }

        handleCurrentChange(val) {
            this.page = val;
            this.searchList();
        }

        showDetail(){
        
        }

        dateFormat(date){
            return moment(date).format("YYYY-MM-DD,H:m:s");
        }

        resizeEvent(){
            this.windowHeight = document.documentElement.clientHeight;
            this.height = this.windowHeight - 210;
        }
        getShanxuan() {
            // debugger
            this.$refs.componentChild.getShow();
            this.conmonDisabled = true;
            this.list='journal'
            this.windowHeight = document.documentElement.clientHeight;
            this.height = this.windowHeight - 210 - 95;
        }
        condition(data) {
            this.page = 1
            //console.log(moment(data.user2[0]).format('YYYY-MM-DD HH:mm:ss'))
            this.cinemaName = data.user
            this.cinemaCode = data.user1
            this.createTimeBegin = data.user4.length==0?'':moment(data.user4[0]).format('YYYY-MM-DD HH:mm:ss')
            this.createTimeEnd = data.user4.length==0?'':moment(data.user4[1]).format('YYYY-MM-DD HH:mm:ss')
            this.confirmTimeBegin = data.user5.length==0?'':moment(data.user5[0]).format('YYYY-MM-DD HH:mm:ss')
            this.confirmTimeEnd = data.user5.length==0?'':moment(data.user5[1]).format('YYYY-MM-DD HH:mm:ss')
            this.status = data.user7
            this.searchList()

            // this.windowHeight = document.documentElement.clientHeight;
            // this.height = this.windowHeight - 210 + 80;
        }
        conmonDisabledNone(conmonDisabled) {
            
            this.conmonDisabled = false;
            this.cinemaName = conmonDisabled.user;
            this.cinemaCode = conmonDisabled.user1;
            this.createTimeBegin =''
            this.createTimeEnd = ''
            this.confirmTimeBegin =''
            this.confirmTimeEnd =''
            this.status = conmonDisabled.user7
            this.windowHeight = document.documentElement.clientHeight;
            this.height = this.windowHeight - 210;
            this.searchList();
        }
       
        created(){
            const me = this;
            this.resizeEvent();
            this.searchList();
            window.onresize = () => {
                return (() => {
                    me.resizeEvent();
                })()
            };
        };
        mounted(){   
                  
        };
        
    }
</script>
<style lang="scss" scoped>
    @import '../../styles/login.scss';
   
</style>